namespace Common.Unity.Extensions.Configuration
{
	public abstract class ObjectConfigurator<ObjectType,ConfigurationType> : IObjectConfigurator<ConfigurationType>
		where ConfigurationType : IObjectConfiguration
	{
		readonly ConfigurationType configuration;

		public ObjectConfigurator( ConfigurationType configuration )
		{
			this.configuration = configuration;
		}

		protected ConfigurationType Configuration
		{
			get { return configuration; }
		}

		ConfigurationType IObjectConfigurator<ConfigurationType>.Configuration
		{
			get { return Configuration; }
		}

		protected abstract void PerformConfiguration( ObjectType target );

		public void Configure( object target )
		{
			Microsoft.Practices.Unity.Utility.Guard.ArgumentNotNull( target, "target" );
			Microsoft.Practices.Unity.Utility.Guard.TypeIsAssignable( typeof(ObjectType), target.GetType(), "target" );
			PerformConfiguration( (ObjectType)target );
		}
	}
}